sgdk: psg.h File Reference

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Defines | Functions
psg.h File Reference

PSG support. More...

Go to the source code of this file.

## Defines

#define | PSG_PORT 0xC00011
#define | PSG_ENVELOPE_MIN 15
#define | PSG_ENVELOPE_MAX 0
#define | PSG_NOISE_TYPE_PERIODIC 0
#define | PSG_NOISE_TYPE_WHITE 1
#define | PSG_NOISE_FREQ_CLOCK2 0
#define | PSG_NOISE_FREQ_CLOCK4 1
#define | PSG_NOISE_FREQ_CLOCK8 2
#define | PSG_NOISE_FREQ_TONE3 3

## Functions

void | PSG_init ()
| Initialize PSG chip.
void | PSG_write (u8 data)
| Write to PSG port.
void | PSG_setEnvelope (u8 channel, u8 value)
| Set envelope level.
void | PSG_setTone (u8 channel, u16 value)
| Set tone.
void | PSG_setFrequency (u8 channel, u16 value)
| Set frequency.
void | PSG_setNoise (u8 type, u8 frequency)
| Set noise type and frequency.

## Detailed Description

PSG support.

Author:
  Stephane Dallongeville

Date:
  08/2011

This unit provides access to the PSG through the 68000 CPU

## Define Documentation

#define PSG_ENVELOPE_MAX 0

Maximum PSG envelope value.

#define PSG_ENVELOPE_MIN 15

Minimum PSG envelope value.

#define PSG_NOISE_FREQ_CLOCK2 0

Noise frequency = PSG clock / 2 (less coarse).

#define PSG_NOISE_FREQ_CLOCK4 1

Noise frequency = PSG clock / 4.

#define PSG_NOISE_FREQ_CLOCK8 2

Noise frequency = PSG clock / 8 (more coarse).

#define PSG_NOISE_FREQ_TONE3 3

Noise frequency = Tone generator #3.

#define PSG_NOISE_TYPE_PERIODIC 0

Periodic noise type (like low-frequency tone).

#define PSG_NOISE_TYPE_WHITE 1

White noise type (hiss).

#define PSG_PORT 0xC00011

PSG port address.

## Function Documentation

void PSG_setEnvelope | ( | u8 | channel,
|  | u8 | value
| ) |  |

Set envelope level.

Parameters:

  channel | Channel we want to set envelope (0-3).
  value | Envelope level to set (PSG_ENVELOPE_MIN - PSG_ENVELOPE_MAX).

Set envelope level for the specified PSG channel.

void PSG_setFrequency | ( | u8 | channel,
|  | u16 | value
| ) |  |

Set frequency.

Parameters:

  channel | Channel we want to set frequency (0-3).
  value | Frequency value to set in Hz (0-4095).

Set frequency for the specified PSG channel.
This method actually converts the specified frequency value in PSG tone value.

void PSG_setNoise | ( | u8 | type,
|  | u8 | frequency
| ) |  |

Set noise type and frequency.

Parameters:

  type | Noise type, accepted values are: PSG_NOISE_TYPE_PERIODIC PSG_NOISE_TYPE_WHITE
  frequency | Noise frequency, accepted values are: PSG_NOISE_FREQ_CLOCK2 PSG_NOISE_FREQ_CLOCK4 PSG_NOISE_FREQ_CLOCK8 PSG_NOISE_FREQ_TONE3

void PSG_setTone | ( | u8 | channel,
|  | u16 | value
| ) |  |

Set tone.

Parameters:

  channel | Channel we want to set tone (0-3).
  value | Tone value to set (0-1023).

Set direct tone value for the specified PSG channel.

void PSG_write | ( | u8 | data | ) |

Write to PSG port.

Parameters:

  data | value to write to the port.

Write the specified value to PSG data port.

All Classes Files Functions Variables Typedefs Enumerations Defines